Image Processing Method and Apparatus

ABSTRACT

An image processing method and apparatus, the image processing method including receiving a first largest coding unit of an image, where the first largest coding unit is a currently received largest coding unit; determining a compensation parameter of the first largest coding unit; performing pixel compensation on at least one area of the first largest coding unit according to the compensation parameter of the first largest coding unit; and performing pixel compensation on at least one area, on which pixel compensation is not performed, of a second largest coding unit according to a compensation parameter of the second largest coding unit, where the second largest coding unit is a previously received largest coding unit adjacent to the first largest coding unit.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of International Application No.PCT/CN2014/070130, filed on Jan. 4, 2014, which claims priority toChinese Patent Application No. 201310250219.2, filed on Jun. 21, 2013,both of which are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present invention relates to the field of image processingtechnologies, and in particular, to an image processing method andapparatus.

BACKGROUND

The sample adaptive offset (SAO) technology is a coding technology newlyadded to the high efficiency video coding (HEVC) standard. A SAOcompensator is placed behind a deblocking filter, and the SAOcompensator determines a corresponding compensation parameter byclassifying and counting pixels of a reconstructed image on whichdeblocking filtering is performed, and then performs pixel compensationon the image, thereby reducing distortion, improving a compression rate,and reducing bitstreams. The compensation parameter includes a sub-bandoffset compensation value, an edge offset compensation value, and thelike. The compensation parameter indicates a SAO compensation methodthat needs to be used by a largest coding unit, including sub-bandoffset compensation, edge offset compensation, needing no compensation,and the like.

In the prior art, for an application at a largest coding unit (LCU)level in the HEVC standard, when the SAO compensator determines thatedge offset compensation needs to be performed on a current LCU, pixelcompensation needs to be performed on the entire current LCU by usingpixels of LCUs that surround and are adjacent to the current LCU(including LCUs above, below, on the left of, on the right of, on theupper right of, on the lower right of, on the upper left of, and on thelower left of the current LCU). Therefore, pixel compensation cannot beperformed on the current LCU until the LCU on the lower right of acurrently received LCU is received.

Therefore, compared with the deblocking filter placed before the SAOcompensator, the SAO compensator has a latency of more than one LCU row,and this latency is great, which cannot meet a highly time sensitivescenario. In addition, because compared with the deblocking filter, theSAO compensator has a latency of more than one LCU row, the SAOcompensator further needs to buffer a received LCU on which pixelcompensation is not performed. If an LCU has a size of N*N pixels, and awidth of an image is X pixels, where X≧N and both X and N are positiveintegers, N*X+2*N*N pixels need to be buffered. Therefore, an amount ofdata that needs to be buffered is large, and occupied resources aresubstantial, causing an increase of costs.

SUMMARY

In view of this, the present invention provides an image processingmethod and apparatus, which can perform, without latency, pixelcompensation processing immediately after an LCU is received, and caneffectively reduce the amount of buffered data.

According to a first aspect, the present invention provides an imageprocessing method, where each largest coding unit includes at least twoareas, and the method includes receiving a first largest coding unit ofan image, where the first largest coding unit is a currently receivedlargest coding unit; determining a compensation parameter of the firstlargest coding unit; performing pixel compensation on at least one areaof the first largest coding unit according to the compensation parameterof the first largest coding unit; and performing pixel compensation onat least one area, on which pixel compensation is not performed, of asecond largest coding unit according to a compensation parameter of thesecond largest coding unit, where the second largest coding unit is apreviously received largest coding unit adjacent to the first largestcoding unit.

In a first possible implementation manner of the first aspect, thedetermining a compensation parameter of the first largest coding unit isdetermining the compensation parameter of the first largest coding unitaccording to pixels of the first largest coding unit; or, determiningthe compensation parameter of the first largest coding unit according topixels of the second largest coding unit and pixels of the first largestcoding unit.

With reference to the first aspect or the first possible implementationmanner of the first aspect, in a second possible implementation manner,after the determining a compensation parameter of the first largestcoding unit, the method further includes storing the compensationparameter of the first largest coding unit, where the compensationparameter is used for pixel compensation afterwards on an area, on whichpixel compensation is not performed, in the first largest coding unit.

With reference to the first aspect, the first possible implementationmanner of the first aspect, or the second possible implementation mannerof the first aspect, in a third possible implementation manner, theperforming pixel compensation on at least one area of the first largestcoding unit according to the compensation parameter of the first largestcoding unit is performing pixel compensation on at least one area of thefirst largest coding unit according to the compensation parameter of thefirst largest coding unit by using the pixels of the first largestcoding unit; or, performing pixel compensation on at least one area ofthe first largest coding unit according to the compensation parameter ofthe first largest coding unit by using the pixels of the first largestcoding unit and the pixels of the second largest coding unit.

With reference to the first aspect, the first possible implementationmanner of the first aspect, the second possible implementation manner ofthe first aspect, or the third possible implementation manner of thefirst aspect, in a fourth possible implementation manner, the performingpixel compensation on at least one area, on which pixel compensation isnot performed, of a second largest coding unit according to acompensation parameter of the second largest coding unit is performingpixel compensation on at least one area, on which pixel compensation isnot performed, of the second largest coding unit according to thecompensation parameter of the second largest coding unit by using thepixels of the second largest coding unit; or, performing pixelcompensation on at least one area, on which pixel compensation is notperformed, of the second largest coding unit according to thecompensation parameter of the second largest coding unit by using thepixels of the second largest coding unit and pixels of a receivedlargest coding unit adjacent to the second largest coding unit.

With reference to the first aspect, the first possible implementationmanner of the first aspect, the second possible implementation manner ofthe first aspect, the third possible implementation manner of the firstaspect, or the fourth possible implementation manner of the firstaspect, in a fifth possible implementation manner, the image is an imageon which deblocking filtering is not performed or an image on whichdeblocking filtering is performed.

According to a second aspect, the present invention provides an imageprocessing apparatus, where each largest coding unit includes at leasttwo areas, and the apparatus includes a receiving unit configured toreceive a first largest coding unit of an image, where the first largestcoding unit is a currently received largest coding unit; a determiningunit configured to determine a compensation parameter of the firstlargest coding unit; and a compensation unit configured to perform pixelcompensation on at least one area of the first largest coding unitaccording to the compensation parameter of the first largest codingunit, where the compensation unit is further configured to perform pixelcompensation on at least one area, on which pixel compensation is notperformed, of a second largest coding unit according to a compensationparameter of the second largest coding unit, where the second largestcoding unit is a previously received largest coding unit adjacent to thefirst largest coding unit.

In a first possible implementation manner of the second aspect, thedetermining unit is configured to determine the compensation parameterof the first largest coding unit according to pixels of the firstlargest coding unit; or, determine the compensation parameter of thefirst largest coding unit according to pixels of the second largestcoding unit and pixels of the first largest coding unit.

With reference to the second aspect or the first possible implementationmanner of the second aspect, in a second possible implementation manner,the apparatus further includes a storage unit configured to store thecompensation parameter of the first largest coding unit, where thecompensation parameter is used for pixel compensation afterwards on anarea, on which pixel compensation is not performed, in the first largestcoding unit.

With reference to the second aspect, the first possible implementationmanner of the second aspect, or the second possible implementationmanner of the second aspect, in a third possible implementation manner,the compensation unit is configured to perform pixel compensation on atleast one area of the first largest coding unit according to thecompensation parameter of the first largest coding unit by using thepixels of the first largest coding unit; or, perform pixel compensationon at least one area of the first largest coding unit according to thecompensation parameter of the first largest coding unit by using thepixels of the first largest coding unit and the pixels of the secondlargest coding unit.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, or the third possible implementation manner of thesecond aspect, in a fourth possible implementation manner, thecompensation unit is configured to perform pixel compensation on atleast one area, on which pixel compensation is not performed, of thesecond largest coding unit according to the compensation parameter ofthe second largest coding unit by using the pixels of the second largestcoding unit; or, perform pixel compensation on at least one area, onwhich pixel compensation is not performed, of the second largest codingunit according to the compensation parameter of the second largestcoding unit by using the pixels of the second largest coding unit andpixels of a received largest coding unit adjacent to the second largestcoding unit.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, the third possible implementation manner of thesecond aspect, or the fourth possible implementation manner of thesecond aspect, in a fifth possible implementation manner, the image isan image on which deblocking filtering is not performed or an image onwhich deblocking filtering is performed.

According to the foregoing solutions, because each LCU of an imageincludes at least two areas, and pixel compensation is separatelyperformed on at least one area of a current LCU and at least one area,on which pixel compensation is not performed, of a previously receivedLCU adjacent to the current LCU. Therefore, after a compensationparameter of the current LCU is determined, pixel compensation can bedirectly performed, without a latency, on at least one area of thecurrent LCU by using pixels of the current LCU and pixels of thereceived LCU adjacent to the current LCU; and only an area, on whichpixel compensation is not performed, in the received LCU needs to bebuffered, which can effectively reduce the amount of buffered data.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic flowchart of an image processing method accordingto Embodiment 1 of the present invention;

FIG. 2 is a schematic flowchart of an image processing method accordingto Embodiment 2 of the present invention;

FIG. 3 is a schematic diagram of an image on which pixel compensationprocessing is performed according to Embodiment 2 of the presentinvention;

FIG. 4 is a schematic flowchart of an image processing method accordingto Embodiment 3 of the present invention;

FIG. 5 is a schematic diagram of an image on which pixel compensationprocessing is performed according to Embodiment 3 of the presentinvention;

FIG. 6 is a schematic structural diagram of an image processingapparatus according to Embodiment 4 of the present invention; and

FIG. 7 is another schematic structural diagram of an image processingapparatus according to Embodiment 4 of the present invention.

DESCRIPTION OF EMBODIMENTS

To make the objectives, technical solutions, and advantages of thepresent invention clearer, the following further describes the presentinvention in detail with reference to the accompanying drawings. Thedescribed embodiments are merely some but not all of the embodiments ofthe present invention. All other embodiments obtained by a person ofordinary skill in the art based on the embodiments of the presentinvention without creative efforts shall fall within the protectionscope of the present invention.

An image processing method provided in Embodiment 1 of the presentinvention is described below in detail by using FIG. 1 as an example.FIG. 1 is a schematic flowchart of the image processing method accordingto Embodiment 1 of the present invention. The image processing method isexecuted by a sample adaptive offset (SAO) compensator. As shown in FIG.1, the image processing method includes the following steps:

Step S101: Receive a first largest coding unit (LCU) of an image.

The first LCU is an LCU currently received by the SAO compensator. TheSAO compensator receives one LCU at every moment, and each LCU includesat least two areas.

Optionally, the image is an image on which deblocking filtering is notperformed or an image on which deblocking filtering is performed.

Step S102: Determine a compensation parameter of the first LCU of theimage.

The compensation parameter includes a sub-band offset compensationvalue, an edge offset compensation value, and the like. When it isdetermined that the LCU does not need sub-band offset compensation oredge offset compensation, the compensation parameter is 0. The SAOcompensator needs to determine whether sub-band offset compensation oredge offset compensation needs to be performed on the first LCU. When itis determined whether sub-band offset compensation is needed, thedetermining may be performed according to only pixels of the first LCU.If sub-band offset compensation needs to be performed, the sub-bandoffset compensation value is calculated. When it is determined whetheredge offset compensation is needed, the determining is performedaccording to edge pixels of the first LCU, or according to edge pixelsof the first LCU and pixels of a second LCU. If edge offset compensationneeds to be performed, the edge offset compensation value is calculated.Finally, the compensation parameter of the first LCU is determined.

The second LCU is a previously received LCU adjacent to the first LCU.The second LCU includes one, two, or three LCUs.

In addition, the SAO compensator stores the compensation parameter ofthe first LCU, so that the compensation parameter is used when pixelcompensation is subsequently performed on an area, on which pixelcompensation is not performed, of the first LCU.

Step S103: Perform pixel compensation on at least one area of the firstLCU according to the compensation parameter of the first LCU.

If the determined compensation parameter of the first LCU is a sub-bandoffset compensation parameter, the SAO compensator performs pixelcompensation on at least one area of the first LCU according to thesub-band offset compensation parameter of the first LCU by using thepixels of the first LCU. If the determined compensation parameter of thefirst LCU is an edge offset compensation parameter, the SAO compensatorperforms edge offset compensation on at least one area of the first LCUaccording to the edge offset compensation parameter of the first LCU byusing the pixels of the first LCU and the pixels of the second LCU.

Step S104: Perform pixel compensation on at least one area, on whichpixel compensation is not performed, of a second LCU according to acompensation parameter of the second LCU.

When the compensation parameter of the second LCU is determined, becausethe compensation parameter of the second LCU is determined when thesecond LCU is previously received, and the compensation parameter of thesecond LCU is stored in the SAO compensator, the stored compensationparameter of the second LCU can be directly used when pixel compensationis performed on the area, on which pixel compensation is not performed,of the second LCU.

If the stored compensation parameter of the second LCU is the sub-bandoffset compensation parameter, the SAO compensator performs sub-bandoffset compensation on at least one area, on which pixel compensation isnot performed, of the second LCU according to the sub-band offsetcompensation parameter of the second LCU by using the pixels of thesecond LCU. If the stored compensation parameter of the second LCU isthe edge offset compensation parameter, the SAO compensator performsedge offset compensation on at least one area, on which pixelcompensation is not performed, of the second LCU according to the edgeoffset compensation parameter of the second LCU by using the pixels ofthe second LCU and pixels of a received LCU adjacent to the second LCU.

It should be noted that, step S103 and step S104 may be performed in anyorder, which is not limited in Embodiment 1 of the present invention.

According to the image processing method provided in Embodiment 1 of thepresent invention, because each LCU of an image includes at least twoareas, an SAO compensator separately performs pixel compensation on atleast one area of a current LCU and at least one area, on which pixelcompensation is not performed, of a previously received LCU adjacent tothe current LCU. Therefore, after a compensation parameter of thecurrent LCU is determined, the SAO compensator can directly perform,without a latency, pixel compensation on at least one area of thecurrent LCU by using pixels of the current LCU and pixels of thereceived LCU adjacent to the current LCU; and only an area, on whichpixel compensation is not performed, in the received LCU needs to bebuffered, which can effectively reduce the amount of buffered data.

An image processing method provided in Embodiment 2 of the presentinvention is described below in detail by using FIG. 2 and FIG. 3 as anexample. FIG. 2 is a schematic flowchart of the image processing methodaccording to Embodiment 2 of the present invention. FIG. 3 is aschematic diagram of an image on which pixel compensation processing isperformed according to Embodiment 2 of the present invention. As shownin FIG. 3, each solid line square represents one LCU, and each LCUincludes four areas. Grey parts indicate areas on which pixelcompensation is performed, blank parts indicate areas on which pixelcompensation is not performed, and slashed parts indicate areas on whichpixel compensation is currently being performed, that is, Embodiment 2of the present invention is described by using an example that LCU 7 iscurrently received.

The image processing method is executed by an SAO compensator. As shownin FIG. 2, the image processing method includes the following steps.

Step S201: Receive LCU 7 of an image.

The SAO compensator receives one LCU at every moment, and each LCUincludes four areas.

An area division manner of each LCU is shown in FIG. 3, and each LCUincludes four identical areas, which are A, B, C, and D. One LCU has asize of N*N pixels, area A has a size of M*K pixels, area B has a sizeof I*K pixels, area C has a size of M*J pixels, and area D has a size ofI*J pixels, where N=M+I=K+J, and N, M, K, I, and J are all positiveintegers.

It may be understood that, an area included by each LCU may be in anysize and of any shape, which is not limited by the area division mannerprovided in this embodiment.

Optionally, the image is an image on which deblocking filtering is notperformed or an image on which deblocking filtering is performed.

Step S202: Determine a compensation parameter of LCU 7.

The compensation parameter includes a sub-band offset compensationvalue, an edge offset compensation value, and the like. When it isdetermined that the LCU does not need sub-band offset compensation oredge offset compensation, the compensation parameter is 0.

The SAO compensator needs to determine whether sub-band offsetcompensation or edge offset compensation needs to be performed on LCU 7.When it is determined whether sub-band offset compensation is needed,the determining is performed by using only pixel of LCU 7. If sub-bandoffset compensation needs to be performed, a sub-band offsetcompensation value is calculated. When it is determined whether edgeoffset compensation is needed, the determining is performed by usingpixels on a lower edge of and on a right edge of LCU 7 and pixels of LCU1, LCU 2, LCU 3, and LCU 6. If edge offset compensation needs to beperformed, an edge offset compensation value is calculated. Finally, thecompensation parameter of LCU 7 is determined.

Step S203: Store the compensation parameter of LCU 7.

The SAO compensator stores the compensation parameter of LCU 7, so thatthe compensation parameter is used when pixel compensation issubsequently performed on an area, on which pixel compensation is notperformed, of LCU 7.

Step S204: Perform pixel compensation on a largest area of LCU 7according to the compensation parameter of LCU 7.

Because LCU 7 is an LCU in an intermediate area of the image, currently,pixel compensation only needs to be performed on the largest area (thatis, area A) of LCU 7.

If the determined compensation parameter of LCU 7 is a sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area A of LCU 7 according to the sub-band offsetcompensation parameter of LCU 7 by using pixels of LCU 7. If thedetermined compensation parameter of LCU 7 is an edge offsetcompensation parameter, the SAO compensator performs edge offsetcompensation on area A of LCU 7 according to the edge offsetcompensation parameter of LCU 7 by using the pixels of LCU 7, LCU 1, LCU2, and LCU 6.

Step S205: Perform pixel compensation on area D of LCU 1 according to acompensation parameter of LCU 1.

LCU 1 is a previously received LCU. Because the compensation parameterof LCU 1 is determined when LCU 1 is previously received, the SAOcompensator has previously stored the compensation parameter of LCU 1,and the SAO compensator directly performs pixel compensation on area Dof LCU 1 according to the stored compensation parameter of LCU 1.

If the stored compensation parameter of LCU 1 is the sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area D of LCU 1 according to the sub-band offsetcompensation parameter of LCU 1 by using the pixels of LCU 1. If thestored compensation parameter of LCU 1 is the edge offset compensationparameter, the SAO compensator performs edge offset compensation on areaD of LCU 1 according to the edge offset compensation parameter of LCU 1by using area A, area B, and area C of LCU 1, and the pixels of LCU 2,LCU 6, and LCU 7.

Step S206: Perform pixel compensation on area C of LCU 2 according to acompensation parameter of LCU 2.

LCU 2 is a previously received LCU. Because the compensation parameterof LCU 2 is determined when the LCU 2 is previously received, the SAOcompensator has previously stored the compensation parameter of LCU 2,and the SAO compensator directly performs pixel compensation on area Cof LCU 2 according to the stored compensation parameter of LCU 2.

If the stored compensation parameter of LCU 2 is the sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area C of LCU 2 according to the sub-band offsetcompensation parameter of LCU 2 by using the pixels of LCU 2. If thestored compensation parameter of LCU 2 is the edge offset compensationparameter, the SAO compensator performs edge offset compensation on areaC of LCU 2 according to the edge offset compensation parameter of LCU 2by using area A, area B, and area D of LCU 2, and the pixels of LCU 1,LCU 6, and LCU 7.

Step S207: Perform pixel compensation on area B of LCU 6 according to acompensation parameter of LCU 6.

LCU 6 is a previously received LCU. Because the compensation parameterof LCU 6 is determined when LCU 6 is previously received, the SAOcompensator has previously stored the compensation parameter of LCU 6,and the SAO compensator directly performs pixel compensation on area Bof LCU 6 according to the stored compensation parameter of LCU 6.

If the stored compensation parameter of LCU 6 is the sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area B of LCU 6 according to the sub-band offsetcompensation parameter of LCU 6 by using the pixels of LCU 6. If thestored compensation parameter of LCU 6 is the edge offset compensationparameter, the SAO compensator performs edge offset compensation on areaB of LCU 6 according to the edge offset compensation parameter of LCU 6by using area A, area C, and area D of LCU 6, and the pixels of LCU 1,LCU 2, and LCU 7.

It should be noted that, for an LCU on an edge of the image, if adetermined compensation parameter of a processed LCU is the sub-bandoffset compensation parameter, sub-band offset compensation needs to beperformed on edge pixels of the LCU; if the determined compensationparameter of the LCU is the edge offset compensation parameter, specificanalyses need to be made: 1) it is determined that 0-degree edge offsetcompensation needs to be performed on the LCU, and if the LCU is on theleft-right edge of the image, pixels on the left-right edge of the imagein the LCU do not need compensation; 2) it is determined that 90-degreeedge offset compensation needs to be performed on the LCU, and if theLCU is on the upper-lower edge of the image, pixels on the upper-loweredge of the image in the LCU do not need compensation; and 3) it isdetermined that 45-degree or 135-degree edge offset compensation needsto be performed on the LCU, and if the LCU is on an edge of the image,no pixels on the edge of the image in the LCU need compensation.

It should be further noted that, step S204 to step S207 may be performedin any order, which is not limited in Embodiment 2 of the presentinvention.

It should be further noted that, if a current LCU is the first LCU ofthe image, but is not in the last column of LCUs of the image, pixelcompensation is only performed on area A of the current LCU; if thecurrent LCU is the last LCU in the first row of the image, but is notthe last LCU of the image or the first LCU of the image, pixelcompensation is performed on area A and area B of the current LCU andarea B of a left LCU; if the current LCU is an LCU in the first row ofLCUs of the image except the first LCU and the last LCU, but is not inthe last row of LCUs of the image, pixel compensation is performed onarea A of the current LCU and area B of the left LCU; if the current LCUis an LCU in the first column of LCUs of the image except the first LCUand the last LCU, but does not belong to the last column of LCUs of theimage, pixel compensation is performed on area A of the current LCU andarea C of an upper LCU; if the current LCU is an LCU in the last columnof LCUs of the image except the first LCU and the last LCU, but does notbelong to the first column of LCUs of the image, when step S204 to stepS207 are correspondingly performed, pixel compensation is also performedon area B of the current LCU and area D of the upper LCU; if the currentLCU is the first LCU in the last row of the image, but is not the firstLCU of the image or the last LCU of the image, pixel compensation isperformed on area A and area C of the current LCU and area C of theupper LCU; if the current LCU is an LCU in the last row of LCUs of theimage except the first LCU and the last LCU, but does not belong to thefirst row of LCUs, when step S204 to step S207 are correspondinglyperformed, pixel compensation is also performed on area C of the currentLCU and area D of the left LCU; if the current LCU is the last LCU ofthe image, but is not in the first column of LCUs of the image or thefirst row of LCUs of the image, when step S204 to step S207 arecorrespondingly performed, pixel compensation is also performed on areaB, area C, and area D of the current LCU, area D of the upper LCU, andarea D of the left LCU, so as to complete pixel compensation for theentire image.

Each LCU of an image is divided into four areas, and pixel compensationis separately performed on at least one area of the current LCU and atleast one area, on which pixel compensation is not performed, of one,two, or three previously received LCUs adjacent to the current LCU.Therefore, after a compensation parameter of the current LCU isdetermined, pixel compensation can be directly performed, without alatency, on at least one area of the current LCU by using pixels of thecurrent LCU and pixels of the received LCU adjacent to the current LCU;and only an area, on which pixel compensation is not performed, in thereceived LCU needs to be buffered, which can effectively reduce theamount of buffered data.

As shown in FIG. 3, after pixel compensation is performed on area A ofLCU 7, area D of LCU 1, area C of LCU 2, and area B of LCU 6, the SAOcompensator needs to buffer an area, on which pixel compensation is notperformed, in each LCU, that is, white areas of each LCU in FIG. 3. Ifthe image has a width of X pixels, where X≧N, and X is a positiveinteger, (J+1)*X+(I+1)*N pixels need to be buffered. Compared with theprior art, this is equivalent that a reduced proportion a of the amountof data that needs to be buffered is:

$\begin{matrix}{a = {\left( {\left( {{N^{*}X} + {2^{*}N^{*}N}} \right) - \left( {{\left( {J + 1} \right)^{*}X} + {\left( {I + 1} \right)^{*}N}} \right)} \right)\text{/}\left( {{N^{*}X} + {2^{*}N^{*}N}} \right)}} \\{= {\left( {{\left( {N - J - 1} \right)^{*}X} + {\left( {{2^{*}N} - I - 1} \right)^{*}N}} \right)\text{/}\left( {{N^{*}X} + {2^{*}N^{*}N}} \right)}}\end{matrix}$

For a general application, when N=64, I=5, and J=4, a >92.18%, that is,compared with the prior art, more than 90% of the amount of the buffereddata of the SAO compensator can be reduced by using the image processingmethod provided in Embodiment 2 of the present invention.

An image processing method provided in Embodiment 3 of the presentinvention is described in detail by using FIG. 4 and FIG. 5 as anexample. FIG. 4 is a schematic flowchart of the image processing methodaccording to Embodiment 3 of the present invention. FIG. 5 is aschematic diagram of an image on which pixel compensation processing isperformed according to Embodiment 3 of the present invention. As shownin FIG. 5, each solid line square represents one LCU, and each LCUincludes three areas. Grey parts indicate areas on which pixelcompensation is performed, blank parts indicate areas on which pixelcompensation is not performed, and slashed parts indicate areas on whichpixel compensation is currently being performed, that is, Embodiment 3of the present invention is described by using an example that LCU 7 iscurrently received.

The image processing method is executed by a SAO compensator. As shownin FIG. 4, the image processing method includes the following steps.

Step S301: Receive LCU 7 of an image.

The SAO compensator receives one LCU at every moment, and each LCUincludes three areas.

An area division manner of each LCU is shown in FIG. 5, and each LCUincludes three identical areas, which are A, B, and C. One LCU has asize of N*N pixels, area A has a size of M*K pixels, the B area has asize of I*K pixels, and area C has a size of N*J pixels, whereN=M+I=K+J, and N, K, I, and J are all positive integers.

It may be understood that, an area included by each LCU may be in anysize and of any shape, which is not limited by the area division mannerprovided in this embodiment.

Optionally, the image is a reconstructed image or a reconstructed imageon which deblocking filtering is performed. The reconstructed imagerefers to an image obtained by adding prediction data of the image toresidual data.

Step S302: Determine a compensation parameter of LCU 7.

The compensation parameter includes: a sub-band offset compensationvalue, an edge offset compensation value, and the like. When it isdetermined that the LCU does not need sub-band offset compensation oredge offset compensation, the compensation parameter is 0.

The SAO compensator needs to determine whether sub-band offsetcompensation or edge offset compensation needs to be performed on LCU 7.When it is determined whether sub-band offset compensation is needed,the determining is performed by using only pixels of LCU 7. If sub-bandoffset compensation needs to be performed, a sub-band offsetcompensation value is calculated. When it is determined whether edgeoffset compensation is needed, the determining is performed by usingpixels on a lower edge of and on a right edge of LCU 7 and pixels of LCU1, LCU 2, LCU 3, and LCU 6. If edge offset compensation needs to beperformed, an edge offset compensation value is calculated. Finally, thecompensation parameter of LCU 7 is determined.

Step S303: Store the compensation parameter of LCU 7.

The SAO compensator stores the compensation parameter of LCU 7, so thatthe compensation parameter is used when pixel compensation issubsequently performed on an area, on which pixel compensation is notperformed, of LCU 7.

Step S304: Perform pixel compensation on a largest area of LCU 7according to the compensation parameter of LCU 7.

Because LCU 7 is an LCU in an intermediate area of the image, currently,pixel compensation only needs to be performed on the largest area (thatis, area A) of LCU 7.

If the determined compensation parameter of LCU 7 is a sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area A of LCU 7 according to the sub-band offsetcompensation parameter of LCU 7 by using the pixels of LCU 7. If thedetermined compensation parameter of LCU 7 is an edge offsetcompensation parameter, the SAO compensator performs edge offsetcompensation on area A of LCU 7 according to the edge offsetcompensation parameter of LCU 7 by using the pixels of LCU 7, LCU 1, LCU2, and LCU 6.

Step S305: Perform pixel compensation on area C of LCU 1 according to acompensation parameter of LCU 1.

LCU 1 is a previously received LCU. Because the compensation parameterof LCU 1 is determined when LCU 1 is previously received, the SAOcompensator has previously stored the compensation parameter of LCU 1,and the SAO compensator directly performs pixel compensation on area Cof LCU 1 according to the stored compensation parameter of LCU 1.

If the stored compensation parameter of LCU 1 is the sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area C of LCU 1 according to the sub-band offsetcompensation parameter of LCU 1 by using pixels of LCU 1. If the storedcompensation parameter of LCU 1 is the edge offset compensationparameter, the SAO compensator performs edge offset compensation on areaC of LCU 1 according to the edge offset compensation parameter of LCU 1by using area A and area B of LCU 1, and the pixels of LCU 2, LCU 6, andLCU 7.

It should be noted that, because the left side of area C of LCU 1 is anedge of the image, when pixel compensation is performed on area C of LCU1, if it is determined that the compensation parameter of LCU 1 is theedge offset compensation parameter, and when edge offset compensationneeds to be performed by using left and right pixels adjacent to eachother, edge offset compensation does not need to be performed on theleftmost column of pixels of LCU 1.

It should be noted that, for an LCU on an edge of the image, if adetermined compensation parameter of a processed LCU is the sub-bandoffset compensation parameter, sub-band offset compensation needs to beperformed on edge pixels of the LCU; if the determined compensationparameter of the LCU is the edge offset compensation parameter, specificanalyses need to be made: 1) it is determined that 0-degree edge offsetcompensation needs to be performed on the LCU, and if the LCU is on theleft-right edge of the image, pixels on the left-right edge of the imagein the LCU do not need compensation; 2) it is determined that 90-degreeedge offset compensation needs to be performed on the LCU, and if theLCU is on the upper-lower edge of the image, pixels on the upper-loweredge of the image in the LCU do not need compensation; and 3) it isdetermined that 45-degree or 135-degree edge offset compensation needsto be performed on the LCU, and if the LCU is on an edge of the image,no pixels on the edge of the image in the LCU need compensation.

Step S306: Perform pixel compensation on area B of LCU 6 according to acompensation parameter of LCU 6.

LCU 6 is a previously received LCU. Because the compensation parameterof LCU 6 is determined when LCU 6 is previously received, the SAOcompensator has previously stored the compensation parameter of LCU 6,and the SAO compensator directly performs pixel compensation on area Bof LCU 6 according to the stored compensation parameter of LCU 6.

If the stored compensation parameter of LCU 6 is the sub-band offsetcompensation parameter, the SAO compensator performs sub-band offsetcompensation on area B of LCU 6 according to the sub-band offsetcompensation parameter of LCU 6 by using pixels of LCU 6. If the storedcompensation parameter of LCU 6 is the edge offset compensationparameter, the SAO compensator performs edge offset compensation on areaB of LCU 6 according to the edge offset compensation parameter of LCU 6by using area A and area B of LCU 6, and the pixels of LCU 1, LCU 2, andLCU 7.

It should be noted that, step S304 to step S306 may be performed in anyorder, which is not limited in Embodiment 3 of the present invention.

It should be further noted that, if a current LCU is in the first columnof LCUs of the image, but is not in the last column of LCUs of theimage, pixel compensation is only performed on area A of the currentLCU; if the current LCU is the last LCU in the first row of the image,but not the last LCU of the image or the first LCU of the image, pixelcompensation is performed on area A and area B of the current LCU andarea B of a left LCU; if the current LCU is an LCU in the first row ofLCUs of the image except the first LCU and the last LCU, but is not inthe last row of LCUs of the image, pixel compensation is performed onarea A of the current LCU and area B of the left LCU; if the current LCUis an LCU in the last column of LCUs of the image except the first LCUand the last LCU, but does not belong to the first column of LCUs of theimage, when step S304 to step S306 are correspondingly performed, pixelcompensation is also performed on area B of the current LCU and area Cof an upper LCU; if the current LCU is an LCU in the last row of LCUs ofthe image except the first LCU and the last LCU, but does not belong tothe first row of LCUs, when step S304 to step S306 are correspondinglyperformed, pixel compensation is also performed on area C of the leftLCU; if the current LCU is the last LCU of the image, but is not in thefirst column of LCUs of the image or in the first row of LCUs of theimage, when step S304 to step S306 are correspondingly performed, pixelcompensation is also performed on area B and area C of the current LCU,area C of the upper LCU, and area C of the left LCU, so as to completepixel compensation on the entire image.

Each LCU of an image is divided into three areas, and pixel compensationis separately performed on at least one area of the current LCU and atleast one area, on which pixel compensation is not performed, of one,two, or three previously received LCUs adjacent to the current LCU.Therefore, after a compensation parameter of the current LCU isdetermined, pixel compensation can be directly performed, without alatency, on at least one area of the current LCU by using internalpixels of the current LCU and pixels of the received LCU adjacent to thecurrent LCU; and only an area, on which pixel compensation is notperformed, in the received LCU needs to be buffered, which caneffectively reduce the amount of buffered data.

As shown in FIG. 5, after pixel compensation is performed on area A ofLCU 7, area D of LCU 1, area C of LCU 2, and area B of LCU 6, the SAOcompensator needs to buffer an area, on which pixel compensation is notperformed, in each LCU, that is, white areas of each LCU in FIG. 5. Ifthe image has a width of X pixels, where X≧N, and X is a positiveinteger, (J+1)*(X+N)+(I+1)*N pixels need to be buffered. Compared withthe prior art, this is equivalent that a reduced proportion a of theamount of data that needs to be buffered is:

$\begin{matrix}{a = {\left( {\left( {{N^{*}X} + {2^{*}N^{*}N}} \right) - \left( {{\left( {J + 1} \right)^{*}\left( {X + N} \right)} + {\left( {I + 1} \right)^{*}N}} \right)} \right)\text{/}\left( {{N^{*}X} + {2^{*}N^{*}N}} \right)}} \\{= {\left( {{\left( {N - J - 1} \right)^{*}X} + {\left( {{2^{*}N} - I - J - 2} \right)^{*}N}} \right)\text{/}\left( {{N^{*}X} + {2^{*}N^{*}N}} \right)}}\end{matrix}$

For a general application, when N=64, I=5, and J=4, a >91.4%, that is,compared with the prior art, more than 90% of the amount of the buffereddata of the SAO compensator can be reduced by using the image processingmethod provided in Embodiment 3 of the present invention.

An image processing apparatus provided in Embodiment 4 of the presentinvention is described below in detail by using FIG. 6 as an example.FIG. 6 is a schematic structural diagram of the image processingapparatus according to Embodiment 4 of the present invention. The imageprocessing apparatus is applied to an SAO compensator, and is configuredto implement the image processing method provided in Embodiment 1,Embodiment 2, and Embodiment 3 of the present invention.

As shown in FIG. 6, the image processing apparatus includes a receivingunit 410, a determining unit 420, and a compensation unit 430.

The receiving unit 410 is configured to receive a first LCU of an image.

The first LCU is an LCU currently received by the receiving unit 410.The receiving unit 410 receives one LCU at every moment, and each LCUincludes at least two areas.

Optionally, the image is an image on which deblocking filtering is notperformed or an image on which deblocking filtering is performed.

The determining unit 420 is configured to determine a compensationparameter of the first LCU of the image.

The compensation parameter includes: a sub-band offset compensationvalue, an edge offset compensation value, and the like. When it isdetermined that the LCU does not need sub-band offset compensation oredge offset compensation, the compensation parameter is 0.

The determining unit 420 needs to determine whether sub-band offsetcompensation or edge offset compensation needs to be performed on thefirst LCU. When it is determined whether sub-band offset compensation isneeded, the determining may be performed according to only pixels of thefirst LCU. If sub-band offset compensation needs to be performed, thesub-band offset compensation value is calculated. When it is determinedwhether edge offset compensation is needed, the determining is performedaccording to edge pixels of the first LCU, or according to edge pixelsof the first LCU and pixels of a second LCU. If edge offset compensationneeds to be performed, the edge offset compensation value is calculated.Finally, the compensation parameter of the first LCU is determined.

The second LCU is a previously received LCU adjacent to the first LCU.The second LCU includes one, two, or three LCUs.

In addition, as shown in FIG. 7, the image processing apparatus mayfurther include a storage unit 440. The storage unit 440 is configuredto store the compensation parameter of the first LCU, so that thecompensation parameter is used when pixel compensation is subsequentlyperformed on an area, on which pixel compensation is not performed, ofthe first LCU.

The compensation unit 430 is configured to perform pixel compensation onat least one area of the first LCU according to the compensationparameter of the first LCU.

If the determined compensation parameter of the first LCU is a sub-bandoffset compensation parameter, the compensation unit 430 performs pixelcompensation on at least one area of the first LCU according to thesub-band offset compensation parameter of the first LCU by using thepixels of the first LCU. If the determined compensation parameter of thefirst LCU is an edge offset compensation parameter, the compensationunit 430 performs edge offset compensation on at least one area of thefirst LCU according to the edge offset compensation parameter of thefirst LCU by using the pixels of the first LCU and the pixels of thesecond LCU.

The compensation unit 430 is further configured to perform pixelcompensation on at least one area of the second LCU according to acompensation parameter of the second LCU.

When the compensation parameter of the second LCU is determined, becausethe compensation parameter of the second LCU is determined when thesecond LCU is previously received, and the compensation parameter of thesecond LCU is stored in the SAO compensator, the stored compensationparameter of the second LCU can be directly used when pixel compensationis performed on the area, on which pixel compensation is not performed,of the second LCU.

If the stored compensation parameter of the second LCU is the sub-bandoffset compensation parameter, the compensation unit 430 performssub-band offset compensation on at least one area, on which pixelcompensation is not performed, of the second LCU according to thesub-band offset compensation parameter of the second LCU by using thepixels of the second LCU. If the stored compensation parameter of thesecond LCU is the edge offset compensation parameter, the compensationunit 430 performs edge offset compensation on at least one area, onwhich pixel compensation is not performed, of the second LCU accordingto the edge offset compensation parameter of the second LCU by using thepixels of the second LCU and pixels of a received LCU adjacent to thesecond LCU.

According to the image processing apparatus provided in Embodiment 4 ofthe present invention, because each LCU of an image includes at leasttwo areas, the image processing apparatus separately performs pixelcompensation on at least one area of a current LCU and at least onearea, on which pixel compensation is not performed, of a previouslyreceived LCU adjacent to the current LCU. Therefore, after acompensation parameter of the current LCU is determined, the imageprocessing apparatus can directly perform, without a latency, pixelcompensation on at least one area of the current LCU by using pixels ofthe current LCU and pixels of the received LCU adjacent to the currentLCU; and only an area, on which pixel compensation is not performed, inthe received LCU needs to be buffered, which can effectively reduce theamount of buffered data.

A person skilled in the art may be further aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, units and algorithm steps may be implemented byelectronic hardware, computer software, or a combination thereof. Toclearly describe the interchangeability between the hardware and thesoftware, the foregoing has generally described compositions and stepsof each example according to functions. Whether the functions areperformed by hardware or software depends on particular applications anddesign constraint conditions of the technical solutions. A personskilled in the art may use different methods to implement the describedfunctions for each particular application, but it should not beconsidered that the implementation goes beyond the scope of the presentinvention.

Steps of methods or algorithms described in the embodiments disclosed inthis specification may be implemented by hardware, a software moduleexecuted by a processor, or a combination thereof. The software modulemay reside in a random access memory (RAM), a memory, a read-only memory(ROM), an electrically programmable ROM, an electrically erasableprogrammable ROM, a register, a hard disk, a removable disk, a compactdisc-read-only memory (CD-ROM), or any other form of storage mediumknown in the art.

In the foregoing specific implementation manners, the objective,technical solutions, and benefits of the present invention are furtherdescribed in detail. It should be understood that the foregoingdescriptions are merely specific implementation manners of the presentinvention, but are not intended to limit the protection scope of thepresent invention. Any modification, equivalent replacement, orimprovement made without departing from the spirit and principle of thepresent invention should fall within the protection scope of the presentinvention.

What is claimed is:
 1. An image processing method, wherein each largestcoding unit comprises at least two areas, and the method comprises:receiving a first largest coding unit of an image, wherein the firstlargest coding unit is a currently received largest coding unit;determining a compensation parameter of the first largest coding unit;performing pixel compensation on at least one area of the first largestcoding unit according to the compensation parameter of the first largestcoding unit; and performing pixel compensation on at least one area, onwhich pixel compensation is not performed, of a second largest codingunit according to a compensation parameter of the second largest codingunit, wherein the second largest coding unit is a previously receivedlargest coding unit adjacent to the first largest coding unit.
 2. Themethod according to claim 1, wherein determining the compensationparameter of the first largest coding unit comprises determining thecompensation parameter of the first largest coding unit according topixels of the first largest coding unit.
 3. The method according toclaim 1, wherein determining the compensation parameter of the firstlargest coding unit comprises determining the compensation parameter ofthe first largest coding unit according to pixels of the second largestcoding unit and pixels of the first largest coding unit.
 4. The methodaccording to claim 1, wherein after determining the compensationparameter of the first largest coding unit, the method further comprisesstoring the compensation parameter of the first largest coding unit,wherein the compensation parameter is used for pixel compensationafterwards on an area, on which pixel compensation is not performed, inthe first largest coding unit.
 5. The method according to claim 1,wherein performing pixel compensation on the at least one area of thefirst largest coding unit according to the compensation parameter of thefirst largest coding unit comprises performing pixel compensation on atleast one area of the first largest coding unit according to thecompensation parameter of the first largest coding unit by using pixelsof the first largest coding unit.
 6. The method according to claim 1,wherein performing pixel compensation on the at least one area of thefirst largest coding unit according to the compensation parameter of thefirst largest coding unit comprises performing pixel compensation on atleast one area of the first largest coding unit according to thecompensation parameter of the first largest coding unit by using thepixels of the first largest coding unit and the pixels of the secondlargest coding unit.
 7. The method according to claim 1, whereinperforming pixel compensation on the at least one area, on which pixelcompensation is not performed, of the second largest coding unitaccording to the compensation parameter of the second largest codingunit comprises performing pixel compensation on at least one area, onwhich pixel compensation is not performed, of the second largest codingunit according to the compensation parameter of the second largestcoding unit by using the pixels of the second largest coding unit. 8.The method according to claim 1, wherein performing pixel compensationon the at least one area, on which pixel compensation is not performed,of the second largest coding unit according to the compensationparameter of the second largest coding unit comprises performing pixelcompensation on at least one area, on which pixel compensation is notperformed, of the second largest coding unit according to thecompensation parameter of the second largest coding unit by using thepixels of the second largest coding unit and pixels of a receivedlargest coding unit adjacent to the second largest coding unit.
 9. Themethod according to claim 1, wherein the image is an image on whichdeblocking filtering is not performed.
 10. The method according to claim1, wherein the image is an image on which deblocking filtering isperformed.
 11. An image processing apparatus, wherein each largestcoding unit comprises at least two areas, the apparatus comprising: areceiving unit configured to receive a first largest coding unit of animage, wherein the first largest coding unit is a currently receivedlargest coding unit; a determining unit configured to determine acompensation parameter of the first largest coding unit; and acompensation unit configured to perform pixel compensation on at leastone area of the first largest coding unit according to the compensationparameter of the first largest coding unit, wherein the compensationunit is further configured to perform pixel compensation on at least onearea, on which pixel compensation is not performed, of a second largestcoding unit according to a compensation parameter of the second largestcoding unit, wherein the second largest coding unit is a previouslyreceived largest coding unit adjacent to the first largest coding unit.12. The apparatus according to claim 11, wherein the determining unit isfurther configured to determine the compensation parameter of the firstlargest coding unit according to pixels of the first largest codingunit.
 13. The apparatus according to claim 11, wherein the determiningunit is configured to determine the compensation parameter of the firstlargest coding unit according to pixels of the second largest codingunit and pixels of the first largest coding unit.
 14. The apparatusaccording to claim 11, further comprising a storage unit configured tostore the compensation parameter of the first largest coding unit,wherein the compensation parameter is used for pixel compensationafterwards on an area, on which pixel compensation is not performed, inthe first largest coding unit.
 15. The apparatus according to claim 11,wherein the compensation unit is configured to perform pixelcompensation on at least one area of the first largest coding unitaccording to the compensation parameter of the first largest coding unitby using the pixels of the first largest coding unit.
 16. The apparatusaccording to claim 11, wherein the compensation unit is configured toperform pixel compensation on at least one area of the first largestcoding unit according to the compensation parameter of the first largestcoding unit by using the pixels of the first largest coding unit and thepixels of the second largest coding unit.
 17. The apparatus according toclaim 11, wherein the compensation unit is further configured to performpixel compensation on at least one area, on which pixel compensation isnot performed, of the second largest coding unit according to thecompensation parameter of the second largest coding unit by using thepixels of the second largest coding unit;
 18. The apparatus according toclaim 11, wherein the compensation unit is configured to perform pixelcompensation on at least one area, on which pixel compensation is notperformed, of the second largest coding unit according to thecompensation parameter of the second largest coding unit by using thepixels of the second largest coding unit and pixels of a receivedlargest coding unit adjacent to the second largest coding unit.
 19. Theapparatus according to claim 11, wherein the image is an image on whichdeblocking filtering is not performed.
 20. The apparatus according toclaim 11, wherein the image is an image on which deblocking filtering isperformed.